package com.xc.controller;

import com.xc.dto.ResultDTO;
import com.xc.entity.RoleEntity;
import com.xc.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//restful 增加post，修改put，删除delete，查询get
@RestController
@RequestMapping("/xc/role")
@Api(tags = "角色管理")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @PostMapping()
    @ApiOperation(value = "角色增加",notes = "角色增加接口的说明")
    public ResultDTO add(@RequestBody RoleEntity roleEntity) {
        return roleService.add(roleEntity);
    }

    @PutMapping()
    @ApiOperation("角色修改")
    public ResultDTO update(@RequestBody RoleEntity roleEntity) {
        return roleService.update(roleEntity);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("角色删除")
    public ResultDTO delete(RoleEntity roleEntity) {
        return roleService.delete(roleEntity);
    }

    @GetMapping()
    @ApiOperation("角色查询所有")
    public ResultDTO findAll(RoleEntity roleEntity) {

        return roleService.findAll(roleEntity);
    }
    @PutMapping("/field")
    public ResultDTO field(RoleEntity roleEntity) {
        return roleService.field(roleEntity);
    }

    @GetMapping("/{id}")
    public ResultDTO findById(RoleEntity roleEntity) {
        return roleService.findById(roleEntity);
    }

    @GetMapping("/count")
    public ResultDTO count(RoleEntity roleEntity) {
        return roleService.count(roleEntity);
    }
}
